package com.szeldon.pj.jps.qres;

import java.util.HashSet;
import java.util.Set;

public class BagResult extends AbstractQueryResult {

    private Set<AbstractQueryResult> elements = new HashSet<AbstractQueryResult>();

    /**
     * 
     * @param results
     */
    public BagResult(Set<AbstractQueryResult> results) {
        for (AbstractQueryResult currentResult : results) {
            elements.add(currentResult);
        }
    }

    public BagResult() {
		
	}

	@Override
    public String toString() {
        StringBuilder builder = new StringBuilder("bag(");
        int i = 0;
        for (AbstractQueryResult currentElement : elements) {
            builder.append((i++) + "=" + currentElement.toString());
            if (i < elements.size()) {
                builder.append(", ");
            }
        }
        builder.append(")");
        return builder.toString();
    }

    public int getElementsSize() {
        return elements.size();
    }

    public Set<AbstractQueryResult> getElements() {
        return elements;
    }

    public void addResult(AbstractQueryResult result) {
    	elements.add(result);
    }

	@Override
	public int compareTo(AbstractQueryResult result) {
		// TODO Auto-generated method stub
		return 0;
	}
}
